package org.rcloud.io.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.rcloud.io.Utils.LikeVo;
import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.mapper.ActivityMapper;
import org.rcloud.io.mapper.ArticleMapper;
import org.rcloud.io.model.Activity;
import org.rcloud.io.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2019/3/2.
 */
@Service(value = "ActivityService")
public class ActivityServiceImpl implements ActivityService{
    @Autowired
    private ActivityMapper activityMapper;

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public ResultVo deleteByPrimaryKey(Activity activity) {

        if (activity.equals("") || activity == null){
            return ResultVo.setError("数据为空");
        } else {
            try {
                Integer i = activityMapper.deleteByPrimaryKey(activity);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo insert(Activity record) {

        if (record.equals("") || record == null){
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                Integer insert = activityMapper.insert(record);
                return ResultVo.setOK(insert);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo insertSelective(Activity record) {

        if (record.equals("") || record == null){
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                Integer i = activityMapper.insertSelective(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo selectByPrimaryKey(Activity record) {

        if (record.equals("") || record == null){
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                Activity activity = activityMapper.selectByPrimaryKey(record);
                return ResultVo.setOK(activity);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo updateByPrimaryKeySelective(Activity record) {

        if (record.equals("") || record == null){
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                Integer i = activityMapper.updateByPrimaryKeySelective(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo updateByPrimaryKey(Activity record) {

        if (record.equals("") || record == null){
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                Integer i = activityMapper.updateByPrimaryKey(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }
}
